const service = require("../services/dailySentence");

class Controller {
    async getOne(req, res) {
        try {
            const body = await service.getOne(req.query);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }

    async list(req, res) {
        try {
            const body = await service.list(req.query);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }

    async add(req, res) {
        try {
            const body = await service.add(req.body);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }

    async update(req, res) {
        try {
            const body = await service.update(req.body);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }

    async del(req, res) {
        try {
            const body = await service.del(req.body.id);
            res.json(body);
        } catch (err) {
            res.json({
                code: 500,
                message: "error",
                result: {},
            });
        }
    }
}

module.exports = new Controller();
